
/*
 * @Author: linZeJian
 * @Date: 2022-02-14 15:40:19
 * @LastEditors: linZeJian
 * @LastEditTime: 2022-03-23 16:14:29
 * @Description:
 */

import request from "@/utils/request";
// 不加   + ''  会报ts语法错误
const filebaseIP = process.env.VUE_APP_FILEBASE_API;

class filebaseUrl {
  constructor() {}

  /**
   * @description: 上传文件
   * @param {any} obj
   * @return {*}
   */
  async uploadFiles(obj) {
    let name = new Date().getTime();
    let res = await request({
      headers: { "Content-Type": "multipart/form-data" },
      baseURL: filebaseIP,
      method: "POST",
      url: `/api/v1/app/formfile/${name}`,
      data: obj,
    });
    return res;
  }

  /**
   * @description: 发送粘贴截图
   * @param {*} data
   * @return {*}
   */
  async uploadParseImage(data) {
    let name = new Date().getTime();
    let res = await request({
      headers: { "Content-Type": "multipart/form-data" },
      baseURL: filebaseIP,
      method: "POST",
      url: `/api/v1/app/files?format=base64&type=jpeg&name=${name}&size=-1`,
      data: data,
    });
    return res;
  }

  /**
   * @description: 下载查看文件
   * @param {any} obj
   * @return {*}
   */
  async dowmloadFiles(obj) {
    let name = new Date().getTime();
    let res = await request({
      headers: { "Content-Type": "multipart/form-data" },
      baseURL: filebaseIP,
      method: "POST",
      url: `/api/v1/app/files?format=base64&name=${name}&size=-1`,
      data: obj,
    });
    return res;
  }
}
let FilebaseUrl = new filebaseUrl();
export default FilebaseUrl;
// import FilebaseUrl from "@/api/filebase";
// await FilebaseUrl.uploadFiles(obj);
